custom_build: add the HOST environment variable
authorCody P Schafer <dev@codyps.com>
Wed, 3 Dec 2014 18:09:46 +0000 (13:09 -0500)
committerCody P Schafer <dev@codyps.com>
Thu, 4 Dec 2014 04:33:41 +0000 (23:33 -0500)
src/cargo/ops/cargo_rustc/custom_build.rs
src/doc/build-script.md
tests/test_cargo_compile_custom_build.rs

index 6791e66afe395a6ba1a27dd5cb17013b3238e28b..07ccbaf5f77bdd0be24ee46410d136323a75fc50 100644 (file)
@@ -61,7 +61,8 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
                      }))
                      .env("DEBUG", Some(profile.get_debug().to_string()))
                      .env("OPT_LEVEL", Some(profile.get_opt_level().to_string()))
-                     .env("PROFILE", Some(profile.get_env()));
+                     .env("PROFILE", Some(profile.get_env()))
+                     .env("HOST", Some(cx.config.rustc_host()));
 
     // Be sure to pass along all enabled features for this package, this is the
     // last piece of statically known information that we have.
index f5ece41c382df29b347cdb0b24623d03523a1430..3a3f0ea59c227f04c4dfbfe5c687a80672d1c626 100644 (file)
@@ -43,6 +43,7 @@ all passed in the form of environment variables:
 * `TARGET` - the target triple that is being compiled for. Native code should be
              compiled for this triple. Some more information about target
              triples can be found in [clang's own documentation][clang].
+* `HOST` - the host triple of the rust compiler.
 * `NUM_JOBS` - the parallelism specified as the top-level parallelism. This can
                be useful to pass a `-j` parameter to a system like `make`.
 * `CARGO_MANIFEST_DIR` - The directory containing the manifest for the package
index 9ea71f0db15904476ad313e408c2d891f0ea1171..aef3c77e0088f2c2507a1df3faa216d554d7d7fa 100644 (file)
@@ -99,6 +99,8 @@ test!(custom_build_env_vars {
                 assert!(out.as_slice().starts_with(r"{0}"));
                 assert!(Path::new(out).is_dir());
 
+                let _host = os::getenv("HOST").unwrap();
+
                 let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
             }}
         "#,